define(['app'],function(app){return {module: function($scope, $http, eventBusService, httpService, params) {
		$scope.dataInfo = {};	
		$scope.form.fk_unit = 'self';
		$scope.form.state = '00000XSZTM2011040108545142173520036';
		$("#studentInfoTabContent > div").hide();
		$('#home').show();
		//切换标签页
		$scope.checkStudentInfo = function(id){
			$("#studentInfoTabContent > div").hide();
			if(id == "1"){
				$('.prepareTab').removeClass("active");
				$('.home').addClass("active");
				$('#home').show();
			}
			if(id == "2"){
				$('.prepareTab').removeClass("active");
				$('.profile').addClass("active");
				$('#profile').show();
			}
			if(id == "3"){
				$('.prepareTab').removeClass("active");
				$('.messages').addClass("active");
				$('#messages').show();
			}
			if(id == "4"){
				$('.prepareTab').removeClass("active");
				$('.settings').addClass("active");
				$('#settings').show();
			}
			if(id == "5"){
				$('.prepareTab').removeClass("active");
				$('.other').addClass("active");
				$('#other').show();
			}
		}
		httpService.post(app.urls.unit_selectSchoolAndAttach,{"fk_unit":$scope.form.fk_unit},function(data){
			if("0000" === data.code){
				$scope.oldList = data.data;
			}else{
				alert(data.msg);
			}
		});
		//查询年级
		$scope.findGrade = function() {
			if($scope.dataInfo.fk_unit == null) {
				$scope.form.fk_unit = params.fk_unit;
			}else{
				$scope.form.fk_unit = $scope.dataInfo.fk_unit;
			}
			httpService.post(app.urls.grade_selectCenterGrade,{"fk_unit":$scope.form.fk_unit},function(data){
				if("0000" === data.code){
					$scope.gradeList = data.data;
				}else{
					alert(data.msg);
				}
			});
		}
		//获取班级
		$scope.findClass = function() {
			httpService.post(app.urls.class_selectClassName,{"fk_unit":$scope.form.fk_unit,"fk_grade":$scope.form.fk_grade,"status":'0'},function(data){
				if("0000" === data.code){
					$scope.classList = data.data;
				}else{
					alert(data.msg);
				}
			});
		}
		//身份证件类型
		httpService.post(app.urls.dictionary_selectByRule,{fk_rule:"SJAAAAA10236"},function(data){
			if("0000" === data.code){
				$scope.sfzjlxmList = data.data;
			}else{
				alert(data.msg);
			}
		});
		//性别
		httpService.post(app.urls.dictionary_selectByRule,{fk_rule:"SJAAAAA29"},function(data){
			if("0000" === data.code){
				$scope.xbmList = data.data;
			}else{
				alert(data.msg);
			}
		});
		//民族
		httpService.post(app.urls.dictionary_selectByRule,{fk_rule:"SJAAAAA10002"},function(data){
			if("0000" === data.code){
				$scope.mzmList = data.data;
			}else{
				alert(data.msg);
			}
		});
		//国别/地区
		httpService.post(app.urls.dictionary_selectByRule,{fk_rule:"SJAAAAA35"},function(data){
			if("0000" === data.code){
				$scope.gjdqmList = data.data;
			}else{
				alert(data.msg);
			}
		});
		//港澳台侨外
		httpService.post(app.urls.dictionary_selectByRule,{fk_rule:"SJAAAAA10240"},function(data){
			if("0000" === data.code){
				$scope.gatqwmList = data.data;
			}else{
				alert(data.msg);
			}
		});
		//政治面貌
		httpService.post(app.urls.dictionary_selectByRule,{fk_rule:"SJAAAAA10006"},function(data){
			if("0000" === data.code){
				$scope.zzmmList = data.data;
			}else{
				alert(data.msg);
			}
		});
		//健康状况
		httpService.post(app.urls.dictionary_selectByRule,{fk_rule:"SJAAAAA10005"},function(data){
			if("0000" === data.code){
				$scope.cjlxList = data.data;
			}else{
				alert(data.msg);
			}
		});
		//血型
		httpService.post(app.urls.dictionary_selectByRule,{fk_rule:"SJAAAAA10001"},function(data){
			if("0000" === data.code){
				$scope.xxmList = data.data;
			}else{
				alert(data.msg);
			}
		});
		//宗教信仰
		httpService.post(app.urls.dictionary_selectByRule,{fk_rule:"SJAAAAA10003"},function(data){
			if("0000" === data.code){
				$scope.xyzjmList = data.data;
			}else{
				alert(data.msg);
			}
		});
		//学生类别
		httpService.post(app.urls.dictionary_selectByRule,{fk_rule:"SJAAAAA10009"},function(data){
			if("0000" === data.code){
				$scope.xslbmList = data.data;
			}else{
				alert(data.msg);
			}
		});
		//入学方式
		httpService.post(app.urls.dictionary_selectByRule,{fk_rule:"SJAAAAA10025"},function(data){
			if("0000" === data.code){
				$scope.rxfsList = data.data;
			}else{
				alert(data.msg);
			}
		});
		//注册状态
		httpService.post(app.urls.dictionary_selectByRule,{fk_rule:"SJAAAAA10010"},function(data){
			if("0000" === data.code){
				$scope.zcztList = data.data;
			}else{
				alert(data.msg);
			}
		});
		//未注册原因
		httpService.post(app.urls.dictionary_selectByRule,{fk_rule:"SJAAAAA100002"},function(data){
			if("0000" === data.code){
				$scope.wzcyyList = data.data;
			}else{
				alert(data.msg);
			}
		});
		//户口所属省份
		httpService.post(app.urls.dictionary_selectByRule,{fk_rule:"SJAAAAA31"},function(data){
			if("0000" === data.code){
				$scope.hksfList = data.data;
			}else{
				alert(data.msg);
			}
		});
		//户口所属市/区
		$scope.findCity = function(father_id){
			httpService.post(app.urls.dictionary_selectByRule,{fk_rule:"SJAAAAA32","father_id":father_id},function(data){
				if("0000" === data.code){
					$scope.hksqList = data.data;
				}else{
					alert(data.msg);
				}
			});
		}
		//户口所属区县
		$scope.findDistrict= function(father_id){
			httpService.post(app.urls.dictionary_selectByRule,{fk_rule:"SJAAAAA33","father_id":father_id},function(data){
				if("0000" === data.code){
					$scope.hkqxList = data.data;
				}else{
					alert(data.msg);
				}
			});
		}
		//户籍类别
		httpService.post(app.urls.dictionary_selectByRule,{fk_rule:"SJAAAAA10004"},function(data){
			if("0000" === data.code){
				$scope.hjlbList = data.data;
			}else{
				alert(data.msg);
			}
		});
		//户口性质
		httpService.post(app.urls.dictionary_selectByRule,{fk_rule:"SJAAAAA10007"},function(data){
			if("0000" === data.code){
				$scope.hkxzmList = data.data;
			}else{
				alert(data.msg);
			}
		});
		//居住证类型
		httpService.post(app.urls.dictionary_selectByRule,{fk_rule:"SJAAAAA10241"},function(data){
			if("0000" === data.code){
				$scope.jzzlxList = data.data;
			}else{
				alert(data.msg);
			}
		});
		//三峡移民
		httpService.post(app.urls.dictionary_selectByRule,{fk_rule:"SJAAAAA10062"},function(data){
			if("0000" === data.code){
				$scope.sfList = data.data;//是否
			}else{
				alert(data.msg);
			}
		});
		//流动人口
		httpService.post(app.urls.dictionary_selectByRule,{fk_rule:"SJAAAAA10008"},function(data){
			if("0000" === data.code){
				$scope.sfldrkList = data.data;
			}else{
				alert(data.msg);
			}
		});
		//监护人与学生关系
		httpService.post(app.urls.dictionary_selectByRule,{fk_rule:"SJAAAAA100240"},function(data){
			if("0000" === data.code){
				$scope.gxmList = data.data;
			}else{
				alert(data.msg);
			}
		});
		//监护人学历
		httpService.post(app.urls.dictionary_selectByRule,{fk_rule:"SJAAAAA10225"},function(data){
			if("0000" === data.code){
				$scope.xlmList = data.data;
			}else{
				alert(data.msg);
			}
		});
		//是否独生子女
		httpService.post(app.urls.dictionary_selectByRule,{fk_rule:"SJAAAAA10000"},function(data){
			if("0000" === data.code){
				$scope.dszybzList = data.data;
			}else{
				alert(data.msg);
			}
		});
		//是否留守儿童
		httpService.post(app.urls.dictionary_selectByRule,{fk_rule:"SJAAAAA100001"},function(data){
			if("0000" === data.code){
				$scope.sflsetList = data.data;
			}else{
				alert(data.msg);
			}
		});
		//学生状态
		httpService.post(app.urls.dictionary_selectByRule,{fk_rule:"SJAAAAA10061"},function(data){
			if("0000" === data.code){
				$scope.stateList = data.data;
			}else{
				alert(data.msg);
			}
		});
		$scope.Xxz = function(){
			$scope.form.xzz=$scope.form.hkdz;
		}
		$scope.Txdz = function(){
			$scope.form.txdz=$scope.form.xzz;
		}
		$scope.findjhr= function(){
		   eventBusService.publish("modal.page","modules/content/usermanagement/student/jhr");
	   	}
		$scope.family={};
	   $scope.saveForm = function(){
			if($scope.formCheck()){
	   		  $scope.family.sfjhr='1';
			  $scope.form.family = JSON.stringify($scope.family);
			  httpService.post(app.urls.student_selectRepeat,$scope.form,function(data) {
				  if ("0000" === data.code) {
					  httpService.post(app.urls.student_insert,$scope.form, function(data) {
							if ("0000" === data.code) {
								eventBusService.publish("content.page.reload",data);
								$scope.goback();
							} else {
								alert(data.msg);
							}
					  });
				  } else {
						alert(data.msg);
					}
			  });
			}
	   }
	 //返回
	$scope.goback = function(){
		var menu = {"url": "modules/content/usermanagement/student/list?father_id=" + params.father_id};
		eventBusService.publish("modules.content.load", menu);
	}
}}});